package com.blrs.service.process.impl;

import java.util.List;
import java.util.Date;

import com.blrs.common.utils.uuid.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.blrs.mapper.ProcessStageMapper;
import com.blrs.domain.ProcessStage;
import com.blrs.service.process.IProcessStageService;
import com.blrs.common.utils.SecurityUtils;

@Service
public class ProcessStageServiceImpl implements IProcessStageService {
    @Autowired
    private ProcessStageMapper processStageMapper;

    @Override
    public ProcessStage selectProcessStageById(String id) {
        return processStageMapper.selectProcessStageById(id);
    }

    @Override
    public List<ProcessStage> selectProcessStageList(ProcessStage processStage) {
        return processStageMapper.selectProcessStageList(processStage);
    }

    @Override
    public List<ProcessStage> selectProcessStagesByTemplateId(String templateId) {
        return processStageMapper.selectProcessStagesByTemplateId(templateId);
    }

    @Override
    @Transactional
    public int insertProcessStage(ProcessStage processStage) {
        processStage.setId(UUID.randomUUID().toString());
        processStage.setCreationId(SecurityUtils.getUserId());
        processStage.setCreationName(SecurityUtils.getUsername());
        processStage.setCreationTime(new Date());
        return processStageMapper.insertProcessStage(processStage);
    }

    @Override
    @Transactional
    public int updateProcessStage(ProcessStage processStage) {
        processStage.setUpdateId(SecurityUtils.getUserId());
        processStage.setUpdateName(SecurityUtils.getUsername());
        processStage.setUpdateTime(new Date());
        return processStageMapper.updateProcessStage(processStage);
    }

    @Override
    @Transactional
    public int deleteProcessStageByIds(String[] ids) {
        return processStageMapper.deleteProcessStageByIds(ids);
    }

    @Override
    @Transactional
    public int deleteProcessStageById(String id) {
        return processStageMapper.deleteProcessStageById(id);
    }
} 